﻿// -------------------------------------------------------------------------
//    @FileName         :    NFOnlineAccMgr.h
//    @Author           :    gaoyi
//    @Date             :    2025-04-03
//    @Email			:    445267987@qq.com
//    @Module           :    NFOnlineAccMgr
//
// -------------------------------------------------------------------------

#pragma once

#include <NFLogicCommon/NFCommDefine.h>

#include "NFComm/NFObjCommon/NFObject.h"
#include "NFComm/NFShmStl/NFShmHashMap.h"
#include "NFLogicCommon/NFLogicShmTypeDefines.h"

#define MAX_ONLINE_ACCOUNT_NUM 1000000

class NFOnlineAcc;

class NFOnlineAccMgr : public NF_OBJECT_GLOBAL_TEMPLATE_MACRO(NFOnlineAccMgr, EOT_ONLINE_ACC_MGR_ID, NFObject)
public:
    NFOnlineAccMgr();
    ~NFOnlineAccMgr() override;
    int CreateInit();
    int ResumeInit();
public:
    NFOnlineAcc* CreateOnlineAcc(uint32_t zoneId, uint64_t uin);
    NFOnlineAcc* FindOnlineAcc(uint32_t zoneId, uint64_t uin);
    int RemoveOnlineAcc(NFOnlineAcc* pAcc);
    int TryDeleteOnlineAcc(NFOnlineAcc* pAcc, int logicSvrId, uint64_t roleId);
private:
    NFShmHashMap<tagAccountAndID, int, MAX_ONLINE_ACCOUNT_NUM> m_accMap;
};
